package org.jeecg.modules.health_records.health_exam.service.impl;

import org.jeecg.modules.health_records.health_exam.entity.HealthExamIndexInfo;
import org.jeecg.modules.health_records.health_exam.mapper.HealthExamIndexInfoMapper;
import org.jeecg.modules.health_records.health_exam.service.IHealthExamIndexInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 周期性健康检查记录表
 * @Author: jeecg-boot
 * @Date:   2025-06-30
 * @Version: V1.0
 */
@Service
public class HealthExamIndexInfoServiceImpl extends ServiceImpl<HealthExamIndexInfoMapper, HealthExamIndexInfo> implements IHealthExamIndexInfoService {

    @Autowired
    private HealthExamIndexInfoMapper healthExamIndexInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthExamIndexInfo> queryByRecordId(HealthExamIndexInfo healthExamIndexInfo) {
        return healthExamIndexInfoMapper.queryByRecordId(Long.valueOf(healthExamIndexInfo.getRecordid()), healthExamIndexInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthExamIndexInfo> queryElecRecord(HealthExamIndexInfo healthExamIndexInfo) {
        return healthExamIndexInfoMapper.queryElecRecord(Long.valueOf(healthExamIndexInfo.getRecordid()), healthExamIndexInfo.getIdNumber());

    }


    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthExamIndexInfo> newQueryElecRecord(HealthExamIndexInfo healthExamIndexInfo) {
        return healthExamIndexInfoMapper.newQueryElecRecord(Long.valueOf(healthExamIndexInfo.getRecordid()),healthExamIndexInfo.getSeeId(),healthExamIndexInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthExamIndexInfo> newQueryPastRecord(HealthExamIndexInfo healthExamIndexInfo) {
        return healthExamIndexInfoMapper.newQueryPastRecord(Long.valueOf(healthExamIndexInfo.getRecordid()),healthExamIndexInfo.getSeeId(),healthExamIndexInfo.getIdNumber());

    }
}
